// Création du serveur et importation des modules serveur
var server =    require('http').createServer(handler);
var mongoose =  require('./mongoose.js').mongoose;
var auth =      require('./Utils/authentication.js');
var grid = require('./Utils/grid.js');
var game = require('./Utils/game.js')

server.listen(1337);
console.log('Server running on port 1337');

// Evenement de démarrage du serveur
function handler (req, res) {
    console.log("Un utilisateur affiche la page.");
}

// Gestion des WebSockets
var io = require('socket.io').listen(server);

io.sockets.on('connection', function (socket) {

    auth.events(socket, io);
    grid.events(socket);
    game.events(io, socket);

});
